package com.zmn.oms.business.impl.warn;

import com.zmn.oms.business.interfaces.warn.OrderWarnBService;
import com.zmn.oms.model.entity.warn.OrderWarn;
import com.zmn.oms.model.entity.warn.OrderWarnQuery;
import com.zmn.oms.services.interfaces.warn.OrderWarnService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 类描述：订单预警信息业务Service实现
 *
 * @author LiangHailong
 * @date 2019/07/29 16:03
 */
@Slf4j
@Service
public class OrderWarnBServiceImpl implements OrderWarnBService {

    @Autowired
    private OrderWarnService orderWarnService;

    @Override
    @Transactional
    public Integer addOrderWarn(OrderWarn orderWarn) {
        Integer rowCount = orderWarnService.insertOrderWarn(orderWarn);
        return rowCount;
    }

    @Override
    public Integer modifyOrderWarnById(OrderWarn orderWarn) {
        OrderWarn model = new OrderWarn();
        model.setWarnId(orderWarn.getWarnId());
        model.setBizStatus(orderWarn.getBizStatus());
        model.setLastSyncResponse(orderWarn.getLastSyncResponse());

        Integer rowCount = orderWarnService.updateOrderWarnById(model);
        return rowCount;
    }

    @Override
    public List<OrderWarn> listOrderWarnsByOrderId(Long orderId) {
        OrderWarnQuery orderWarnQuery = new OrderWarnQuery();
        orderWarnQuery.setOrderId(orderId);

        List<OrderWarn> list = orderWarnService.listOrderWarns(orderWarnQuery);
        return list;
    }

    @Override
    public List<OrderWarn> listOrderWarnsByOuterWarnIds(List<Long> outerWarnIds) {
        if (outerWarnIds == null || outerWarnIds.isEmpty()) {
            return null;
        }

        List<OrderWarn> list = orderWarnService.listOrderWarnsByOuterWarnIds(outerWarnIds);
        return list;
    }
}
